package com.sh.data.engine.web.webapi.controller.management;


import com.sh.data.engine.application.model.dto.base.PagerResponse;
import com.sh.data.engine.application.model.dto.management.OperationLogDTO;
import com.sh.data.engine.application.service.management.OperationLogApplicationService;
import com.sh.data.engine.domain.management.model.param.OperationLogQueryParam;
import com.sh.data.engine.web.webapi.controller.base.response.RestResponseEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Validated
@RestController
@RequestMapping("/management/operation")
@Tag(name = "数据集成-日志管理", description = "日志管理API")
public class OperationLogController {
    @Autowired
    private OperationLogApplicationService operationLogApplicationService;

    @PostMapping("/getOperationLogPageList")
    @Operation(summary = "获取日志列表")
    public RestResponseEntity<PagerResponse<OperationLogDTO>> getOperationLogPageList(@RequestBody OperationLogQueryParam param) {
        {
            var result = operationLogApplicationService.getLogPageList(param);
            return RestResponseEntity.success(result);
        }
    }

    @PostMapping("/export/operationLogs")
    public void exportOperationLogs(@RequestBody OperationLogQueryParam param, HttpServletResponse response) throws IOException {
        operationLogApplicationService.exportOperationLogs(param, response);
    }

}
